<?php

Module::Init('system', 'structure');
$filter = array();
if(!empty($params['block_id'])){
    $filter['block_id'] = $params['block_id'];
}
if(!empty($params['section_id'])){
    //$filter['id'] = $params['section_id'];
    $filter['section_id'] = $params['section_id'];
}
$list = Section::GetList($filter, array('sort' => 'asc'));

if(!empty($params['section_id'])){
    $tree = $list;
}else{
    $tree = Tree($list, "id", "section_id", "sections", true);
}
